#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int compar_int(const void* e1,const void* e2)
{
    return (*(int*)e1 - *(int*)e2);
}
void print(int* p,int sz)
{
    int i = 0;
	for(i=0;i<sz;i++)
	{
	    printf("%d ",*(p+i));
	}
	printf("\n");
}
void swap(char* buf1,char* buf2,int width)
{
    int i = 0;
	for(i=0;i<width;i++)
	{
	    char tmp = *buf1;
		*buf1 = *buf2;
		*buf2 = tmp;
		buf1++;
		buf2++;
	}
}
void bubble_sort(void* base,int sz,int width,int (*compar)(const void* e1,const void*e2))
{
    int i = 0;
	int j = 0;
	for(i=0;i<sz-1;i++)
	{
	    for(j=0;j<sz-i-1;j++)
		{
		    if((compar((char*)base+j*width,(char*)base+(j+1)*width))>0)
			{
			    swap((char*)base+j*width,(char*)base+(j+1)*width,width);
			}
		}																						
	}
}
int main ()
{
	int arr[] = {2,1,4,3,6,5,7,9,8,0};
	int sz = sizeof(arr)/sizeof(arr[0]);
	bubble_sort(arr,sz,sizeof(arr[0]),compar_int);
	print(arr,sz);
    return 0;
}